package com.powernode.feign.fallbackfactory;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.powernode.domain.Category;
import com.powernode.domain.Prod;
import com.powernode.domain.ProdTagReference;
import com.powernode.feign.SearchProductFeign;
import com.powernode.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @create: 2024/7/24
 * @author: gyhe10
 * @description:
 **/

@Component
@Slf4j
public class SearchProductFeignFallbackFactory implements FallbackFactory<SearchProductFeign> {
    @Override
    public SearchProductFeign create(Throwable cause) {
        return new SearchProductFeign() {
            @Override
            public Result<Page<ProdTagReference>> getProdTagReferencePageByTagId(Long tagId, Long current, Long size) {
                log.error("远程调用产品业务模块接口失败，原因：{}，接口：根据商品分组标签id分页查询商品和分组标签关联对象列表失败", cause.getMessage());
                return null;
            }

            @Override
            public Result<List<Prod>> getProdListByIds(List<Long> prodIds) {
                log.error("远程调用产品业务模块接口失败，原因：{}，接口：根据商品id集合查询商品列表失败", cause.getMessage());
                return null;
            }

            @Override
            public Result<List<Category>> getCategoryListByParentId(Long parentId) {
                log.error("远程调用产品业务模块接口失败，原因：{}，接口：根据父节点id查询商品类目列表失败", cause.getMessage());
                return null;
            }

            @Override
            public Result<List<Prod>> getProdListByCategoryIds(List<Long> categoryIds) {
                log.error("远程调用产品业务模块接口失败，原因：{}，接口：根据商品类目id集合查询商品列表失败", cause.getMessage());
                return null;
            }
        };
    }
}
